package com.psycho.sys.api.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.psycho.sys.api.entity.Announcement;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.util.List;

/**
 * 系统公告Mapper接口
 */
@Mapper
public interface AnnouncementMapper extends BaseMapper<Announcement> {
    /**
     * 分页查询公告列表
     */
    Page<Announcement> selectAnnouncementPage(Page<Announcement> page,
            @Param("title") String title,
            @Param("type") Integer type,
            @Param("status") Integer status);

    /**
     * 查询有效的公告列表
     */
    List<Announcement> selectActiveAnnouncements(@Param("type") Integer type);

    /**
     * 更新公告状态
     */
    int updateAnnouncementStatus(@Param("id") Long id, @Param("status") Integer status);

    /**
     * 批量删除公告
     */
    int batchDeleteAnnouncements(@Param("ids") List<Long> ids);

    /**
     * 统计各类型公告数量
     */
    Integer countAnnouncementsByType(@Param("type") Integer type);

    /**
     * 查询最新的公告
     */
    List<Announcement> selectLatestAnnouncements(@Param("limit") Integer limit);
}